﻿<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>BootStrap Table使用</title>
    <link href="~/css/bootstrap-select.css" rel="stylesheet" />
    <link href="~/css/bootstrap-table.css" rel="stylesheet" />
    <link href="~/css/bootstrap.css" rel="stylesheet" />
    <link href="~/css/ui-dialog.css" rel="stylesheet" />
    <link href="/css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
    <link href="~/css/labelauty.css" rel="stylesheet" />
    <script src="~/js/jquery.min.js"></script>
    <script src="~/js/bootstrap.js"></script>
    <script src="~/js/bootstrap-table.js"></script>
    <script src="~/js/bootstrap-select.js"></script>
    <script src="~/js/bootstrap-table-zh-CN.js"></script>
    <script src="~/js/jquery.unobtrusive-ajax.js"></script>
    <script src="/js/content.min.js?v=1.0.0"></script>
    <script src="~/js/dialog-plus-min.js"></script>
    <script src="~/js/bootstrap-table-export.js"></script>
    <script src="~/js/tableExport.js"></script>
    <script src="~/js/labelauty.js"></script>
    <script src="~/js/lsj/navigation.js"></script>
</head>



<body>
    <div class="panel-body" style="padding-bottom:0px;">
        <div id="toolbar" class="btn-group">
            <button id="btn_add" type="button" class="btn btn-default">
                <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>新增
            </button>
            <button id="btn_edit" type="button" class="btn btn-default">
                <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>修改
            </button>
            <button id="btn_delete" type="button" class="btn btn-default">
                <span class="glyphicon glyphicon-remove" aria-hidden="true"></span>删除
            </button>
        </div>
        <table id="tb_departments"></table>
    </div>



    @using Web.helper;
    @using (Ajax.BeginForm("AddNav", new { }, new AjaxOptions() { HttpMethod = "Post", OnSuccess = "tips(data)", OnBegin = "ValidateLog" }))
    {
        <div class="modal fade bs-example-modal-sm" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" style="z-index:1000">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="myModalLabel">新增</h4>
                    </div>
                    <div class="modal-body">
                        <input type="hidden" name="id" class="form-control" id="id">
                        <div class="form-group">
                            <label for="txt_departmentname">上级标识</label>
                             @Html.Raw(Html.select_nav())
                        </div>
                        <div class="form-group">
                            <label for="txt_departmentname">图标</label>
                            <input type="text" name="txt_icon_url" class="form-control" id="txt_icon_url" placeholder="图标">
                        </div>
                        <div class="form-group">
                            <label for="txt_parentdepartment">标题</label>
                            <input type="text" name="txt_title" class="form-control" id="txt_title" placeholder="标题" required="">
                        </div>
                        <div class="form-group">
                            <label for="txt_parentdepartment">路径</label>
                            <input type="text" name="txt_link_url" class="form-control" id="txt_link_url" placeholder="路径" required="">
                        </div>
                        <div class="form-group">
                            <label for="txt_parentdepartment">排序</label>
                            <input type="text" name="txt_sort_id" class="form-control" id="txt_sort_id" value="99" placeholder="数字越小越靠前" onkeyup="value=value.replace(/[^\d]/g,'')">
                        </div>
                        <div class="form-group">
                            <label for="txt_departmentlevel">显示</label>
                            <input type="hidden" id="txt_is_lock" name="txt_is_lock" value="√" /> @*用一个隐藏元素保存选中状态*@
                            <div class="rdo">
                                <input type="radio" name="rdo" class="rdolist" checked="checked" />
                                <label class="rdobox">
                                    <span class="check-image"></span>
                                    <span class="radiobox-content">显示</span>
                                </label>
                                <input type="radio" name="rdo" class="rdolist" />
                                <label class="rdobox">
                                    <span class="check-image"></span>
                                    <span class="radiobox-content">隐藏</span>
                                </label>
                            </div>
                        </div>

                        <div class="form-group">
                            <label for="txt_parentdepartment">权限</label>
                            <input type="hidden" id="txt_action_type" name="txt_action_type" value="√" /> @*用一个隐藏元素保存选中状态*@
                            <!-- 多选 -->
                            <div class="fuxuan">

                                <input type="checkbox" name="chk" class="chklist" checked="checked" />
                                <!--  -->
                                <label class="chkbox">
                                    <span class="check-image"></span>
                                    <span class="radiobox-content">查看</span>
                                </label>
                                <!--  -->
                                <input type="checkbox" name="chk" class="chklist" />
                                <!--  -->
                                <label class="chkbox">
                                    <span class="check-image"></span>
                                    <span class="radiobox-content">添加</span>
                                </label>
                                <!--  -->
                                <input type="checkbox" name="chk" class="chklist" />
                                <!--  -->
                                <label class="chkbox">
                                    <span class="check-image"></span>
                                    <span class="radiobox-content">修改</span>
                                </label>
                                <!--  -->
                                <input type="checkbox" name="chk" class="chklist" />
                                <!--  -->
                                <label class="chkbox">
                                    <span class="check-image"></span>
                                    <span class="radiobox-content">删除</span>
                                </label>
                                <!--  -->
                                <input type="checkbox" name="chk" class="chklist" />
                                <!--  -->
                                <label class="chkbox">
                                    <span class="check-image"></span>
                                    <span class="radiobox-content">审核</span>
                                </label>
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button class="btn btn-default" data-dismiss="modal"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span>关闭</button>
                        <button class="btn btn-primary block full-width m-b" id="btn_submit" onclick="onck()"><span class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span>保存</button>
                    </div>

                </div>
            </div>
        </div>
    }
    <script>
        $(document).ready(function () {
            //参数{input类名，选择类型(单选or多选)}
            $(".rdolist").labelauty("rdolist", "rdo");
            $(".chklist").labelauty("chklist", "check");

            $(".rdobox").click(function () {
                if ($(this).html() == $(".rdobox:first").html()) {
                    //显示
                    $("#txt_is_lock").val("√");
                } else
                {
                    //隐藏
                    $("#txt_is_lock").val("×");
                }
            })
        });
        $('#myModal').on('show.bs.modal', function (e) {
            $(".chkbox").each(function () {
                $(this).prev().prop("checked", "");
                $(this).removeClass("checked");
                $(this).addClass("unchecked");
                $(this).children(".check-image").css("background", "url(../img/input-unchecked.png)");
            });
        })

    </script>

</body>
</html>
<script>
    //提交的onclick,此时还可以修改表单里面的值,且后台可以获取
    function onck()
    {
        $('.selectpicker').selectpicker('refresh');//不加这个,默认显示无法获取

        //获取多选的值
        var action_type = "";
        $(".chkbox").each(function () {
            if ($(this).prev().prop("checked") == true) {
                action_type += $(this).children(".radiobox-content").html() + ",";
            }
        })
        if (action_type.length > 0)
        {
            action_type = action_type.substring(0, action_type.length - 1);
            $("#txt_action_type").val(action_type);

        } else
        {
            $("#txt_action_type").val('');
        }
    }


    //登录前js验证,此时修改表单里面的值后台无法获取
    function ValidateLog() {

    }


    //登录回调函数
    function tips(data) {
        var d = dialog({
            padding: 30,
            content: data.msg
        });

        if (data.status == 0) {
            //添加成功

            //显示模态框
            d.show();
            //先关闭主窗体
            $('#myModal').modal('hide')
            //刷新数据
            $('#tb_departments').bootstrapTable('refresh', { url: '/Templet/GetNavList' });
            //关闭提示模态框
            setTimeout(function () {
                d.close().remove();
            }, 2000);
        } else if (data.pitchId != "") {
            point(data.pitchId, data.msg);
        } else {
            //添加失败
            d = dialog({
                padding:30,
                content: data.msg
            });
            //关闭提示模态框
            setTimeout(function () {
                d.close().remove();
            }, 2000);
        }
    }

    //输出提示信息
    function point(id,content)
    {
        var follow = document.getElementById(id);
        var d = dialog({
            align: 'bottom',
            content: '<span class="label label-warning">!</span> ' + content
        });
        d.show(follow);
        setTimeout(function () {
            d.close().remove();
        }, 2000);
    }
</script>